package com.qdu.mapper;

import com.qdu.bean.bikeWritable;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class TempAvgMapper extends Mapper<LongWritable, Text, bikeWritable, DoubleWritable> {

    bikeWritable bw=new bikeWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] data = line.split(",");
        String[] datetime = data[0].split(" ");
        String[] date = datetime[0].split("/");

        bw.set1(date[0]+"-"+date[1]);
        context.write(bw,new DoubleWritable(Double.parseDouble(data[5])));

    }
}
